#!/bin/bash

function camel {
 b=$(echo $1 | sed 's/.//')
 a=$(echo $1 | sed "s%${b}\$%%" | tr '[a-z]' '[A-Z]')
 echo "${a}${b}"
}
function upcase {
 echo $1 | tr '[a-z]' '[A-Z]'
}

for lname in sun mercury venus earth moon mars jupiter saturn uranus neptune pluto
do
 cname=$(camel ${lname})
 uname=$(upcase ${lname})
 target=${cname}.java

 cat<<EOF >${target}
/*
 * OREKIT-X
 * Copyright 2002-2008 CS Communication & Systemes
 * 
 * Parts of this software package have been licensed to CS
 * Communication & Systemes (CS) under one or more contributor license
 * agreements.  See the NOTICE file distributed with this work for
 * additional information.
 *  
 * This is an experimental copy of OREKIT from www.orekit.org.
 * Please use the original OREKIT from orekit.org for normal work
 * unrelated to this research project.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 * may not use this file except in compliance with the License.  You
 * may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.  See the License for the specific language governing
 * permissions and limitations under the License.
 */
package ore.bodies;

/**
 * ${cname}
 */
public class ${cname} 
   extends SolarSystemBody
{ 
    protected static ${cname} Instance;
    public static ${cname} Instance(){
        if (null == Instance)
            Instance = new ${cname}();
        return Instance;
    }


    protected ${cname}()
        throws OrekitException
    {
        super(SolarSystemBody.getSolarSystemBarycenter().getFrame(),
              JPLEphemerides.EphemerisType.${uname},
              "${cname} centered EME2000");

        Instance = this;
    }
}
EOF
 ls -l  ${target}
done
